package org.devocean.groupbuying.service.impl;

import java.util.List;

import org.devocean.groupbuying.dao.ContactDAO;
import org.devocean.groupbuying.domain.Contact;
import org.devocean.groupbuying.service.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ContactServiceImpl implements ContactService {

	@Autowired
	private ContactDAO contactDAO;

	@Transactional
	public void add(Contact contact) {
		contactDAO.persiste(contact);
	}

	@Transactional
	public List<Contact> getAllContacts() {

		return contactDAO.listContact();
	}

	@Transactional
	public void removeContact(Integer id) {
		contactDAO.removeContact(id);
	}

	public Contact getContact(Integer id) {
		// TODO Auto-generated method stub
		return contactDAO.findById(id);
	}

	@Transactional
	public Contact updateContact(Contact contact) {
		// TODO Auto-generated method stub
		return contactDAO.updateContact(contact);
	}
}
